package com.demo.widget.meis;

import com.demo.widget.BaseAbility;
import com.demo.widget.ResourceTable;
import com.demo.widget.provider.StackLayoutMangerProvider;

import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.components.Component;
import ohos.agp.components.ListContainer;

public class MainAbility extends BaseAbility {
    private ListContainer mListContainer;
    private String[] nameArray = {
            "GIF圆角",
            "五彩蛛网",
            "小红书\n标签",
            "小红书\n图片裁剪",
            "滚动视差",
            "直播间\n送爱心",
            "shape控件集",
            "仿百度\n图片拖拽",
            "仿头条视频\n拖拽控件",
            "仿摩拜单车\n贴纸动画效果",
            "LOVE 玫瑰",
            "浮动粒子",
            "直播间点赞",
            "跳动的文本",
            "豆瓣弹性\n滑动卡片",
            "文字路径",
            "自定义\nLayoutManager"};
    private Class[] targetArray = {
            MeiCornersGifAbility.class,
            MeiSpiderWebAbility.class,
            MeiRandomDragTagAbility.class,
            MeiCropImageAbility.class,
            MeiScrollParallaxAbility.class,
            MeiHeartAbility.class,
            MeiRadiusAbility.class,
            MeiPhotoDragAbility.class,
            MeiVideoDragListAbility.class,
            MeiMoBikeAbility.class,
            MeiRoseAbility.class,
            MeiFireflyAbility.class,
            MeiPraiseAbility.class,
            MeiEvaporateAbility.class,
            MeiScrollViewAbility.class,
            MeiTextPathAbility.class,
            MeiStackLayoutManagerAbility.class};

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main_meis);
        mListContainer = (ListContainer) findComponentById(ResourceTable.Id_list_container);
        mListContainer.setItemProvider(new StackLayoutMangerProvider(this, nameArray));
        mListContainer.setItemClickedListener(new ListContainer.ItemClickedListener() {
            @Override
            public void onItemClicked(ListContainer listContainer, Component component, int i, long l) {
                Intent intent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withAbilityName(targetArray[i])
                        .withBundleName(getBundleName())
                        .build();
                intent.setOperation(operation);
                startAbility(intent);
            }
        });
    }
}
